package com.project2.controller;


import com.project2.bean.CommonData;
import com.project2.bean.ResultVo;
import com.project2.bean.bo.AdminCommentBo;
import com.project2.bean.po.MarketComment;
import com.project2.service.AdminCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("admin/comment")
@RestController
public class AdminCommentController {

    @Autowired
    AdminCommentService adminCommentService;


    /*
    TODO 评论回显
     */
    @RequestMapping("list")
    public ResultVo list(AdminCommentBo commentBo){
        CommonData<MarketComment> goodsComment = adminCommentService.getGoodsComment(commentBo);
        return ResultVo.ok(goodsComment);
    }

    /*
    TODO 评论删除
     */
    @RequestMapping("delete")
    public ResultVo delete(@RequestBody MarketComment comment){
        int i = adminCommentService.deleteComment(comment);
        if (i>0){
            return ResultVo.ok();
        }
        return ResultVo.ok("删除失败",401);
    }

}
